<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
  <li class="active"><a href="#red" data-toggle="tab">Tổng sản phẩm (Xuất/Nhập) kho</a></li>
  <li><a href="#orange" data-toggle="tab">Thống kê</a></li>
  <li><a href="#yellow" data-toggle="tab">Sản phẩm</a></li>  
</ul>

<div id="my-tab-content" class="tab-content">
  
  <!-- Tổng sản phẩm (Xuất/Nhập) kho -->
  <div class="tab-pane active" id="red">
      <h1></h1>
      <?php echo isset($warning) ? '<div class="alert bg-danger">'.$warning.'</div>' : "" ?>
      <form class="form-horizontal" role="form" method="post" action="<?=site_url('dashboard/search') ?>">  
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">Chọn ngày</label>    
          <div class="container">
            <div class="col-sm-6" style="height:75px;">
               <div class='col-md-5' style="margin-right:10px;">
                    <div class="form-group">
                        <div class='input-group date' id='datetimepicker8'>
                            <input type='text' name="fromDate" class="form-control" placeholder="Chọn từ ngày" value="<?=isset($fromDate) ? $fromDate : "" ?>" />
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                    </div>
                </div>              
                <div class='col-md-5' style="">
                    <div class="form-group">
                        <div class='input-group date' id='datetimepicker9'>
                            <input type='text' name="toDate" class="form-control" placeholder="tới ngày" value="<?=isset($toDate) ? $toDate : "" ?>"/>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                    </div>
                </div>
            </div>    
            <script type="text/javascript">
                $(function () {
                    $('#datetimepicker8').datetimepicker();
                    $('#datetimepicker9').datetimepicker();
                    $("#datetimepicker8").on("dp.change",function (e) {
                       $('#datetimepicker9').data("DateTimePicker").setMinDate(e.date);
                    });
                    $("#datetimepicker9").on("dp.change",function (e) {
                       $('#datetimepicker8').data("DateTimePicker").setMaxDate(e.date);
                    });
                });
            </script>
            <button type="submit" class="btn btn-primary">Tìm kiếm</button></td>    
          </div>        
        </div>  
      </form>

      <?php if(!empty($showData)): ?>
      <div class="table-responsive">
        <table class="table table-bordered">
          <thead>   
            <tr align="center" class="success">
            <td class="info">Ngày</td>
            <?php foreach ($showData as $key => $value): ?>       
              <td><?=$key; ?></td>
            <?php endforeach; ?>
            <td class="info">Tổng cộng</td>
            </tr>
          </thead>
          <tbody>
            <tr align="center" >
            <td class="info">Nhập kho</td>
            <?php foreach ($showData as $key => $value): ?>       
              <td><?=$value['import']; ?></td>
            <?php endforeach; ?>
            <td class="info"><?=$totalImport; ?></td>
            </tr>
            <tr align="center" >
            <td class="info">Xuất kho</td>
            <?php foreach ($showData as $key => $value): ?>       
              <td><?=$value['export']; ?></td>
            <?php endforeach; ?>
            <td class="info"><?=$totalExport; ?></td>
            </tr>
          </tbody>
        </table>
      </div>      
      <?php endif; ?>
  </div>


  <!-- hiển thị tổng xuất kho, lưu kho -->
  <div class="tab-pane" id="orange">      
      <div class="page-header">
        <h1>Thống kê</h1>
      </div>
      <div class="row">
        <div class="col-sm-4">
          <ul class="list-group">
            <a href="#" class="list-group-item active">
              <span class="glyphicon glyphicon-qrcode"></span> Tổng số sản phẩm
            </a>
            <li class="list-group-item"><span class="glyphicon glyphicon-import"></span> Nhập kho: <?=$totalAllImport; ?></li>
            <li class="list-group-item"><span class="glyphicon glyphicon-export"></span> Xuất kho: <?=$totalAllExport; ?></li>      
            <li class="list-group-item"><span class="glyphicon glyphicon-calendar"></span> Ngày lập thống kê: <?=date('d/m/Y',strtotime('now')) ?></li>      
          </ul>
        </div><!-- /.col-sm-4  
        <!-- <div class="col-sm-4">
          <div class="list-group">
            <a href="#" class="list-group-item active">
              <span class="glyphicon glyphicon-folder-open"></span> Dữ liệu kho
            </a>
            <a href="#" class="list-group-item"><span class="glyphicon glyphicon-exclamation-sign"></span> Kho đầy: <?=$storageInfo['full_load'] ?>(kho)</a>
            <a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok-sign"></span> Kho còn trống: <?=$storageInfo['empty_load'] ?>(kho)</a>
            <a href="#" class="list-group-item"><span class="glyphicon glyphicon-info-sign"></span> Kho đang lưu : <?=$storageInfo['available_load'] ?>(kho)</a>      
          </div>
        </div><!-- /.col-sm-4 --> 
        <!-- <div class="col-sm-4">
          <div class="list-group">
            <a href="#" class="list-group-item active">
              <h4 class="list-group-item-heading"><span clas="glyphicon glyphicon-hdd"></span> Báo cáo hệ thống</h4>      
            </a>
            <a href="#" class="list-group-item">
              <h4 class="list-group-item-heading">Backup</h4>
              <p class="list-group-item-text"><span class="glyphicon glyphicon-pushpin"></span> Dữ liệu backup gần nhất lúc <?=$backup->date_created ?> (tình trạng: thành công)</p>
            </a>
            <a href="#" class="list-group-item">
              <h4 class="list-group-item-heading">Báo cáo nâng cấp hệ thống</h4>
              <p class="list-group-item-text"><span class="glyphicon glyphicon-pushpin"></span> Không có</p>
            </a>      
          </div>
        </div><!-- /.col-sm-4 -->
      </div>
      <!-- hiện thị thành công -->
  </div>

  <div class="tab-pane" id="yellow">      
      <!-- quản lý sản phẩm -->
      <div class="page-header">
        <h1>Sản phẩm</h1>
      </div>
      <?php echo (isset($notify_product) && !empty($notify_product)) ? '<div class="alert bg-success">'.$notify_product.'</div>' : "" ?>
      <form class="form-horizontal" role="form" method="post" action="<?=site_url('dashboard/search') ?>">  
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">Tìm kiếm</label>    
          <div class="col-sm-3">
            <input type="text" name="search" class="form-control" id="inputPassword3" placeholder="Nhập tên sản phẩm hay mã sản phẩm.." value="<?=isset($search) ? $search : "" ?>">
          </div>       
        </div>  
      </form>

      <!-- Tạo sản phẩm mới -->
      <p>
        <a id="go" rel="leanModal" name="signup" class="btn btn-primary" href="#signup">Tạo sản phẩm mới</a> 
      </p>
      <!-- Tạo sản phẩm mới -->


      <div class="table-responsive">
        <table class="table table-bordered table-striped table-hover">
          <thead>
            <tr class="success" align="center">
              <td>Sản phẩm</td>               
              <td>Code</td>
              <td>Hình ảnh</td>
              <td>Giá</td>                    
              <td>Kích hoạt</td>            
              <td>Ngày tạo</td>   
              <td>Thao tác</td>                   
            </tr>
          </thead>
          <tbody>      
            <?php 
              $i = 1;     
              foreach ($products as $row): 
                $product_image = !empty($row->image) ? '<img src="'.base_url('uploads/image/products/'.$row->image).'" class="img-responsive" style="width: 90%">' : '';
                $active_tr = empty($row->active) ? 'class="danger"' : '';
                echo '<tr align="center" '.$active_tr.'>
                    <td>'.$row->title.'</td>              
                    <td>'.$row->code.'</td>
                    <td style="width: 15%;">'.$product_image.'</td>
                    <td>'.$row->price.'</td>
                    <td>'.$row->active.'</td>
                    <td>'.$row->created_at.'</td>
                    <td><a href="'.site_url('product/edit/'.$row->id).'" class="btn btn-primary"><span class="glyphicon glyphicon-pencil"></span> Chỉnh sửa</a></td>                            
                    </tr>';               
                $i++;
              endforeach;
            ?>
          </tbody>
        </table>
        <?= !empty($paging_products) ? "<div class='pull-right'><span>Tổng cộng: $total sản phẩm</span><br>$paging_products</div>" : "" ?>  
      </div>  

      <!-- Show create product form -->
      <div id="signup">
            <div id="signup-ct">
              <div id="signup-header">
                <h2>Tạo sản phẩm mới</h2>
                <p></p>
                <a class="modal_close" href="#"></a>
              </div>
              
              <form action="<?=site_url('product/newProduct') ?>" method="post">     
                <div class="txt-fld">
                  <label for="">Sản phẩm</label>
                  <input id="" class="good_input" name="title" type="text" />
                </div>                  
                <div class="txt-fld">
                  <label for="">Mã</label>
                  <input id="" class="good_input" name="code" type="text" />
                </div>   
                <div class="txt-fld">
                  <label for="">Màu</label>
                  <input id="" class="good_input" name="color" type="text" />
                </div>   
                <div class="txt-fld">
                  <label for="">Giá</label>
                  <input id="" class="good_input" name="price" type="text" />
                </div>
                <div class="txt-fld">
                  <label for="">Giá sale</label>
                  <input id="" class="good_input" name="sale_price" type="text" />
                </div>
                <div class="txt-fld">
                  <label for="">Mô tả</label>
                  <textarea class="good_input" rows="5" cols="50" name="description"></textarea>
                </div>          
                <div class="btn-fld">
                  <button type="submit" name="createBtn" value="createBtn_value">Tạo mới</button>
                </div>
               </form>
            </div>
      </div>
    </div>
</div>